﻿(function() {
    var DataMorph = window.DataMorph || {};

    DataMorph.DatasetParametersViewModel = function(data, processData) {
        var self = this;

        var minFileSize = 1 * 1000 * 1000;
        var maxFileSize = 4 * 1000 * 1000;

        this.ClientId = ko.observable("");
        this.processData = function() {
            processData(self);
        };
        
        this.StorageAccountName = ko.observable(data ? data.StorageAccountName : "").extend({ required: true });
        this.StorageAccountKey = ko.observable(data ? data.StorageAccountKey : "").extend({ required: true });
        this.DataSetName = ko.observable(data ? data.DataSetName : "").extend({ required: true });
        this.NumberOfTags = ko.observable(data ? data.NumberOfTags :  10).extend({ required: true, min: 1, max: 2147483647 });
        this.NumberOfFiles = ko.observable(data ? data.NumberOfFiles : 100).extend({ required: true, min: 1, max: 2147483647 });
        this.MinFileSize = ko.observable(data ? data.MinFileSize : minFileSize).extend({ required: true, min: minFileSize, max: maxFileSize });
        this.MaxFileSize = ko.observable(data ? data.MaxFileSize : maxFileSize).extend({ required: true, min: minFileSize, max: maxFileSize });
        this.StartDate = ko.observable(data ? data.StartDate : new Date());
        this.NumberOfDays = ko.observable(data ? data.NumberOfDays : 10).extend({ required: true, min: 1, max: 1000 });        
        this.newRecord = ko.observable(data == null);
        this.existingRecord = ko.observable(data != null);
    };
})();